<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
                      "http://www.w3.org/TR/html4/strict.dtd"> 
<html> 
  <head> 
    <title>Acceleration Example</title> 
 
    <script type="text/javascript" charset="utf-8" src="phonegap.js"></script> 
    <script type="text/javascript" charset="utf-8"> 
 
    // Wait for PhoneGap to load 
    // 
    function onLoad() { 
        document.addEventListener("deviceready", onDeviceReady, false); 		
    } 
 
    // PhoneGap is ready 
    // 
    function onDeviceReady() { 
        navigator.accelerometer.getCurrentAcceleration(onSuccess, onError); 
    } 
 
    // onSuccess: Get a snapshot of the current acceleration 
    // 
    function onSuccess(acceleration) { 
        alert('Acceleration X: ' + acceleration.x + '\n' + 
              'Acceleration Y: ' + acceleration.y + '\n' + 
              'Acceleration Z: ' + acceleration.z + '\n' + 
              'Timestamp: '      + acceleration.timestamp + '\n'); 
    } 
 
    // onError: Failed to get the acceleration 
    // 
    function onError() { 
        alert('onError!'); 
    } 
 
    </script> 
  </head> 
  <body onload="onLoad()"> 
    <h1>Example</h1> 
    <p>getCurrentAcceleration</p> 
  </body> 
</html> 
